package com.tongji.housediy.view.component3D
{
	import alternativa.engine3d.core.MipMapping;
	import alternativa.engine3d.materials.FlatShadingMaterial;
	import alternativa.engine3d.materials.TextureMaterial;
	
	import flash.display.BitmapData;
	import flash.display.BlendMode;
	import flash.display.GradientType;
	import flash.display.Shape;
	import flash.filters.GradientGlowFilter;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	/**
	 * 
	 * @author xuxunjia
	 * 
	 */	
	
	public class WallMaterial extends TextureMaterial
	{
		private var matr:Matrix;
		private var spot:Shape;
		
		public function WallMaterial(length:Number, height:Number, wallBitmap:BitmapData, underBitmap:BitmapData = null)
		{	
			this.texture = new BitmapData(length, height, false);
			super(texture);
			
			//画墙
			spot = new Shape();
			spot.graphics.clear();
			spot.graphics.beginBitmapFill(wallBitmap);
			spot.graphics.drawRect(0, 0, length, height);
			//画踢脚线
			spot.graphics.beginBitmapFill(underBitmap);
			spot.graphics.drawRect(0, 0, length, 20);
			texture.draw(spot);
			//踢脚线阴影
			spot.graphics.clear();
			spot.graphics.beginGradientFill(GradientType.LINEAR, [0xffffff, 0x666666], [1, 1], [0, 255],new Matrix(0,1,1,0));
			spot.graphics.drawRect(0, 0, length, 18);
			texture.draw(spot,null,null,BlendMode.MULTIPLY);
			//墙面阴影
			matr = new Matrix();
			matr.createGradientBox(2.4 * length, 2.4 * height, 0, -length * 0.6, - height * 1.2);
			spot.graphics.clear();
			spot.graphics.beginGradientFill(GradientType.RADIAL, [0xffffff, 0x000000], [1, 1], [0, 255], matr);
			spot.graphics.drawRect(0, 0, length, height);
			texture.draw(spot,null,null,BlendMode.MULTIPLY);
		}
	}
}